public class Test {
    public static int getElements(int[]array,int index){
        if(array==null){
            throw new  NullPointerException("空指针异常！");
        }
        if(index<0||index>array.length-1){
            throw new IndexOutOfBoundsException("下标越界异常！");
        }
        return array[index];
    }

    public static void main(String[] args) {
        int[]arr={1,2,3};
        getElements(arr,100);
    }
}
